package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

// 查找图书
public class FindOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("查找图书");
        Scanner sc = new Scanner(System.in);
        System.out.println("输入你要找的书籍名称：");
        String name = sc.nextLine();
        BookList bookList1 = new BookList();
        for (int i = 0; i < bookList1.getUsedSize(); i++) {
            Book book = bookList1.getPos(i);// 获取书籍信息
            if (name.equals(book.getName())){// 比较书名
                System.out.println("找到了，信息如下：");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有你所搜索的书籍");
    }
}
